package main;

import java.awt.Frame;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.JFrame;
import javax.swing.JPanel;

public class Home extends JFrame{
	
	private static final String GAME_NAME = "EQUIPE A";
	
	private String name;
	
	
	public Home(){
		super(GAME_NAME);
		config();
		final Hello hello = new Hello();
		hello.getOk().addMouseListener(new MouseAdapter(){	
			@Override
			public void mouseReleased(MouseEvent e) {
				if(!hello.getPlayerName().isEmpty()){
					name = hello.getPlayerName();
					setTitle(GAME_NAME + " - Jogador: " + name);
					hello.setVisible(false);
					setEnabled(true);
				}else hello.error();
			}
		});
		hello.getCancelar().addMouseListener(new MouseAdapter(){	
			@Override
			public void mouseReleased(MouseEvent e) {
				System.exit(0);
			}
		});
	}
	
	private void config(){
		setExtendedState(Frame.MAXIMIZED_BOTH);  
		setVisible(true);
		setEnabled(false);
		add(new Principal());
	}
}
